/**
*   FuzzyEngine - an Simple flex framework 
*   Copyright (C) 2010 Constantin Aldea
*
*   This program is free software: you can redistribute it and/or modify
*   it under the terms of the GNU General Public License as published by
*   the Free Software Foundation, either version 3 of the License, or
*   (at your option) any later version.
*   This program is distributed in the hope that it will be useful,
*   but WITHOUT ANY WARRANTY; without even the implied warranty of
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*   GNU General Public License for more details.
*
*   You should have received a copy of the GNU General Public License
*   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
package main.com.sibilla.gadgets.views {
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.events.MouseEvent;
	import mx.containers.Canvas;
	import mx.containers.ControlBar;
	import mx.containers.Form;
	import mx.containers.FormHeading;
	import mx.containers.VBox;
	import mx.controls.Button;
	import mx.controls.Label;
	import mx.controls.TextArea;
	import mx.managers.PopUpManager;
	public class PopUpWin extends Canvas
	{
		
		public function PopUpWin( __firstListener:Function=null, __secondListener:Function=null )
		{
			super();
			this.width = 300;
			this.setStyle("text-align", "center");
			this.setStyle("backgroundColor", "#E5E4E0");
			//this.setStyle("dropShadowColor ", "#E5E4E0"); 
		
 			this.setStyle("borderStyle", "inset");
			//var _tmpCanvas:Canvas = new Canvas(); 
	 		//_tmpCanvas.setStyle("text-align", "center");
	 		firstListener = __firstListener;
	 		if(__secondListener != null)secondListener = __secondListener;
	 		else secondListener = autoRemoveInstance;
			
		}
		private var _cancelBtn:Button;
		private var _controlBar:ControlBar;
		private var _exportBtn:Button;
		private var _firstListener:Function;
		private var _label:Label;
		private var _message:String;
		private var _secondListener:Function;
		private var _textArea:TextArea;
		
		public function customEmphasis():void{
			_exportBtn.emphasized = false;
		}

		public function get firstListener():Function
		{
			return _firstListener;
		}
	

		public function set firstListener(val:Function):void
		{
			_firstListener = val;
		}
		
		public function get message():String{
			return _label.text;
		}
		
		public function set message(m:String):void
		{
			_label.text = m;
		}

		public function get secondListener():Function
		{
			return _secondListener;
		}
		public function set secondListener(val:Function):void
		{
			_secondListener = val;
		}

		public function get textArea():TextArea
		{
			return _textArea;
		}

		public function set textArea(val:TextArea):void
		{
			_textArea = val;
		}
		
		override protected function createChildren():void{
			var vb:VBox = new VBox;
			vb.setStyle("paddingTop", 3);
			vb.setStyle("paddingBottom", 3);
			vb.percentWidth = 100;
			
			_textArea = new TextArea;
			_textArea.percentWidth = 100;
			_textArea.height = 80;
			var form:Form = new Form;
			var frmHeading:FormHeading = new FormHeading;
			frmHeading.label = "Motivazione";
			form.addChild(frmHeading);
			form.percentWidth = 100;
			form.addChild(_textArea)
			vb.addChild(form);
	 		 
 			_exportBtn =  new Button();
 			_exportBtn.label = "Conferma";
 			_exportBtn.id = "expBtn";
 			_exportBtn.addEventListener(MouseEvent.CLICK, firstListener);
 			_exportBtn.addEventListener(KeyboardEvent.KEY_UP, firstListener);
 			_cancelBtn =  new Button();
 			_cancelBtn.label = "Annulla";
 			_cancelBtn.addEventListener(MouseEvent.CLICK, secondListener);
 			_cancelBtn.addEventListener(KeyboardEvent.KEY_UP, secondListener);
 			//_tmpCanvas.addChild(_cancelBtn);
 			
 			
 			_controlBar = new ControlBar();
 			_controlBar.setStyle("horizontalAlign", "center");
 			_controlBar.addChild(_exportBtn);
 			_controlBar.addChild(_cancelBtn);
 			//_tmpCanvas.addChild(_controlBar);
			vb.addChild(_controlBar);
			this.addChild(vb);
		
		}
		
		
		private function autoRemoveInstance(e:Event):void{
			PopUpManager.removePopUp(this);
		}
	}
	
	
}